<script lang='ts' setup name='Wacth'>  
 import { ref ,computed ,watch } from 'vue' 

 const sum = ref(0)

 // 方法
 function changeSum(){
    sum.value += 1
  }



  watch(sum,(newValue,oldValue)=>{
    console.log("newValue ",newValue+"  ,oldValue:"+oldValue);
  })

</script>  
  
<template>  
    <div class="person">
    <h1>情况一：监视【ref】定义的【基本类型】数据</h1>
    <h2>当前求和为：商品数量{{sum}}</h2>
    <button @click="changeSum">点我sum+1</button>
  </div>

  
</template>  
  
<style scoped>  

</style>  




